package com.leapp.sk.viewdelegate.adapter.notify

import android.content.Context
import android.support.v4.content.ContextCompat
import android.widget.TextView
import com.example.mvp.delegate.BaseAdapterDelegate
import com.leapp.sk.R
import com.leapp.sk.bean.TeacherClassNotifyEntity

/**
 * 班级通知老师端适配器视图托管类
 * @author  chaohaipeng  on 2018/8/9.
 */
class ClassNotifyTeacherAdapterDelegate : BaseAdapterDelegate(){
    override fun getOptionsMenuId(): Int {
        return 0
    }

    override fun initWidget() {
    }

    override fun onDestroy() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.adapter_techer_class_notify
    }

    /**
     * 初始化数据
     */
    fun initData(context: Context, data: TeacherClassNotifyEntity){
        val tv_atcn_notify_time = getView<TextView>(R.id.tv_atcn_notify_time)
        val tv_atcn_notify_title = getView<TextView>(R.id.tv_atcn_notify_title)
        val tv_atcn_notify_readNum = getView<TextView>(R.id.tv_atcn_notify_readNum)
        val tv_atcn_notify_content = getView<TextView>(R.id.tv_atcn_notify_content)
        val tv_atcn_class = getView<TextView>(R.id.tv_atcn_class)
        tv_atcn_notify_time?.text=data.createDate
        tv_atcn_notify_title?.text=data.title
        if (data.noReadCount>0){
            tv_atcn_notify_readNum?.text=String.format(context.resources.getString(R.string.string_message_notify_unread), data.noReadCount)
            tv_atcn_notify_readNum?.setTextColor(ContextCompat.getColor(context,R.color.color_FF4447))
        }else{
            tv_atcn_notify_readNum?.text=context.resources.getString(R.string.string_message_notify_all_read)
            tv_atcn_notify_readNum?.setTextColor(ContextCompat.getColor(context,R.color.color_A3A5A8))
        }
        tv_atcn_notify_content?.text=data.content
        tv_atcn_class?.text=data.classNames
    }


}